package com.joysuch.wwyt.bp.controller;

import com.joysuch.wwyt.bp.bean.investigate.BpInvestigateStoreBean;
import com.joysuch.wwyt.bp.entity.investigate.BpInvestigateStore;
import com.joysuch.wwyt.bp.service.BpInvestigateStoreService;
import com.joysuch.wwyt.core.common.ajax.ResultBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @Author ZhangDong
 * @Date 2020/3/25 10:42
 */
@RestController
@RequestMapping("/bp/investigate/store")
@Api(tags = "隐患管理-检查标准库")
public class BpInvestigateStoreController {

    @Autowired
    private BpInvestigateStoreService bpInvestigateStoreService;

    @PostMapping("/save")
    @RequiresPermissions("bp:investigate:store:save")
    @ApiOperation("新增/修改检查类型")
    public ResultBean save(@RequestBody @Valid BpInvestigateStoreBean bean) {
        return bpInvestigateStoreService.save(bean);
    }

    @GetMapping("/delete/{id}")
    @RequiresPermissions("bp:investigate:store:delete")
    @ApiOperation(value = "根据标准库Id删除")
    @ApiImplicitParam(name = "id", value = "标准库Id", paramType = "path", required = true)
    public ResultBean delete(@PathVariable Long id) {
        return bpInvestigateStoreService.delete(id);
    }

    @GetMapping("/list")
    @ApiOperation(value = "检查标准库列表--树结构输出", response = BpInvestigateStore.class)
    public ResultBean list() {
        return bpInvestigateStoreService.list();
    }

    @GetMapping("/getByParentId/{parentId}")
    @ApiOperation(value = "隐患排查计划-选择检查项目 ", response = BpInvestigateStore.class)
    @ApiImplicitParam(name = "parentId", value = "标准库Id ---第一个输入框传0, 第二个传第一个输入框内容的id", paramType = "path", required = true)
    public ResultBean getByParentId(@PathVariable Long parentId) {
        return bpInvestigateStoreService.getByParentId(parentId);
    }
}
